home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / index.php < prev    next >
PHP Script  |  2010-05-19  |  8KB  |  207 lines

  1. <?php
  2. /**
  3.  * MAIN PAGE
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   NA
  14.  * @package    NA
  15.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  16.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id:$
  19.  * @link       http://www.weezo.net
  20.  * @since      File available since Release 1.0.0
  21.  */
  22.  
  23.  
  24. /**
  25.  * @desc logout user
  26.  *
  27.  */
  28. function indexLogout(){
  29.     $logoutToLoginPage=cfGGetVar('logoutToLoginPage');
  30.  
  31.     // if user is actually connected
  32.     if (isset($_SESSION['userLogged'])){
  33.         // Save icon's position and persistant resources vars (only if single user profile or admin)
  34.         if(WEnv::user()->isAdministrator() || WEnv::user()->getVar('accountType')=='singleUser'){
  35.             // Browse active items (background icons)
  36.             foreach (cfGGetVar('activeItems') as $item) if($item['type']=='icon' && isset($item['resourceFilename']) && $item['x']!==null && $item['y']!==null){
  37.                 foreach (WEnv::user()->getResources() as $rid=>$rfn) if($rfn==$item['resourceFilename']) {
  38.                     WEnv::user()->updateResource($rid,'iconPosition',$item['x'].'x'.$item['y']);
  39.                 }
  40.             }
  41.  
  42.             // Save persistant resources vars
  43.             WEnv::user()->saveVar('savedRVars',false);
  44.  
  45.             // Save user if needed
  46.             WEnv::user()->save();
  47.         }
  48.  
  49.         // inform application of disconnection and log logout
  50.         cfServerSendCommand('log disconnected="'.wSession_id().'"');
  51.  
  52.         // Log it as event
  53.         //if(!cfUGetVar('invisible')) cfLogEvent(cfCaption('logUserLogout',false,false,false,true).' ('.cfUTF8Encode(cfUGetVar('name')).')',EVENT_CONNECTION,S_EVENT_LOGOUT);
  54.  
  55.         // Log disconnection into stats database
  56.         require_once(INCLUDE_DIR.'databaseFunctions.php');
  57.         dbLogDisconnection();
  58.         cfLog(cfCaption('logUserLogout',false,false,false,true).' ('.cfUTF8Encode(cfUGetVar('name').')'.((cfUGetVar('pseudo'))?' - '.cfUGetVar('pseudo'):'')),LOG_INF,true);
  59.  
  60.         // destroy session directory
  61.         if(cfAppUserTempDir(false)) cfUnlinkDir(cfAppUserTempDir(false));
  62.  
  63.         // remove access to doc root subdirs
  64.         cfHtaccessGrant(false,'remove');
  65.     }
  66.     else cfLog('Log out required by non logged user (session has probably expired)',LOG_INF);
  67.  
  68.     // Destroy cookie
  69.     setcookie('WSESSID', '', time()-42000, '/');
  70.  
  71.     // destroy session
  72.     if(!wSession_destroy()){
  73.         wSession_start();
  74.         wSession_destroy();
  75.     }
  76.  
  77.     // Site accessed through portal
  78.     if(($_POST['logout']=='top' && !$logoutToLoginPage) || !cfDirectWebConnectionsAllowed()) {echo '<script langage="javascript">top.location.href="'.APP_SITE.'";</script>'; exit;}
  79.  
  80.     // Else, go back to login page
  81.     require_once(cfAppDocRoot().'/login.php');
  82.     exit();
  83. }
  84.  
  85.  
  86.  
  87.  
  88. // Start session if client send a session id
  89. //if(isset($_COOKIE['WSESSID'])) cfDbg($_COOKIE['WSESSID']);
  90. if(isset($_COOKIE['WSESSID'])) wSession_start();
  91.  
  92.  
  93. /*
  94.  ***************************************************************************************************************************
  95.  * If logout order received, destroy & reload session
  96.  ***************************************************************************************************************************
  97.  */
  98. if(isset($_POST['logout'])) indexLogout();
  99.  
  100.  
  101. // Theme change command received
  102. if(isset($_POST['themeUpdate']) && isset($_POST['themeLevel']) && cfGGetVar('allowUserThemeChange')){
  103.     if($_POST['themeLevel']=='general') cfGSetVar('theme', cfUTF8Decode($_POST['themeUpdate']));
  104.     if($_POST['themeLevel']=='user') cfUSetVar('theme', cfUTF8Decode($_POST['themeUpdate']));
  105.     if($_POST['themeLevel']=='resource') cfRSetVar('theme', cfUTF8Decode($_POST['themeUpdate']));
  106. }
  107. if(isset($_GET['themeUpdate']) && isset($_GET['themeLevel']) && cfGGetVar('allowUserThemeChange')){
  108.     if($_GET['themeLevel']=='general') cfGSetVar('theme', cfUTF8Decode($_GET['themeUpdate']));
  109.     if($_GET['themeLevel']=='user') cfUSetVar('theme', cfUTF8Decode($_GET['themeUpdate']));
  110.     if($_GET['themeLevel']=='resource') cfRSetVar('theme', cfUTF8Decode($_GET['themeUpdate']));
  111. }
  112. // Get user screen size
  113. if (isset($_GET['userScreenWidth'])) cfGSetVar('userScreenWidth',$_GET['userScreenWidth']);
  114. if (isset($_GET['userScreenHeight'])) cfGSetVar('userScreenHeight',$_GET['userScreenHeight']);
  115.  
  116. /*
  117.  ***************************************************************************************************************************
  118.  * If user not logged-in, display authentication form
  119.  ***************************************************************************************************************************
  120.  */
  121. if(!isset($_SESSION['userLogged'])) {
  122.     if(isset($_GET['loginOK'])) $securityEvent=cfCaption('securityNoSession');
  123.     require(cfAppDocRoot().'/login.php');
  124.     exit;
  125. }
  126.  
  127. /*
  128.  ***************************************************************************************************************************
  129.  * User logged-in
  130.  ***************************************************************************************************************************
  131.  */
  132.  
  133. // Standalone resource: redirect to resource
  134. if(cfUGetVar('publishToken')) {header('Location: '.$_SESSION['res'][0]['resourceJsLink']);exit;}
  135.  
  136.  
  137. require(cfAppDocRoot().'/mainFrame.php');
  138. exit;
  139.  
  140.  
  141. // Frameless theme or single-frame theme
  142. if(!cfTGetVar('frames') || cfTGetVar('framelessDesktop')){
  143.     $_ENV['framelessDesktop']=1;
  144.     require(cfAppDocRoot().'/mainFrame.php');
  145.     exit;
  146. }
  147.  
  148. // Get theme layout data
  149. $menuFrameThemeData=cfTGetVar('menuFrame');
  150. $menuFramePosition=$menuFrameThemeData['position'];
  151. $menuFrameSize=$menuFrameThemeData['size'];
  152. $menuFrameScrolling=$menuFrameThemeData['scrolling']; if($menuFrameScrolling===0) $menuFrameScrolling='NO';
  153.  
  154. // 2-frames theme
  155. cfInsertBasicHEAD(false,true);
  156.  
  157. // Get theme information for main panel position
  158. $themeDirectory=cfAppThemeDir(false);
  159.  
  160. // Load menu script
  161. if(file_exists($themeDirectory.'/menu.php')) require($themeDirectory.'/menu.php'); else require(W_THEMES_DIR.'common/menu.php');
  162.  
  163. // Set windows borders total width and total height
  164. $mainFrameThemeData=cfTGetVar('mainFrame');
  165.  
  166. echo '<link rel="shortcut icon" href="favicon.ico"></head>'."\n";
  167. ?>
  168. <script type="text/javascript">
  169. function reloadFrames(){document.location.href='/index.php';}
  170. function resizeMenuFrame(nd){
  171. <?php
  172. if(in_array($menuFramePosition,array('top','left','bottom','right')) && isset($menuFrameSize)){
  173.     switch ($menuFramePosition){
  174.         case 'top': echo "dgi('menuFrame').rows=nd + \",*\";";break;
  175.         case 'bottom': echo "dgi('menuFrame').rows=\"*,\" + nd;";break;
  176.         case 'right': echo "dgi('menuFrame').cols=\"*,\" + nd;";break;
  177.         case 'left': echo "dgi('menuFrame').cols=nd + \",*\";";break;
  178.     }
  179. }
  180. ?>
  181. }
  182. </script>
  183. <?php
  184. if(isset($stretchedBackground)) cfGSetVar('stretchedBackground',$stretchedBackground); else cfGSetVar('stretchedBackground',false);
  185.  
  186. $mfSource='/mainFrame.php';
  187.  
  188. // Set frames
  189.  
  190. switch ($menuFramePosition){
  191.     case 'top': echo '<frameset id="menuFrame" rows="'.$menuFrameSize.',*" frameborder="no" framespacing="0" border="0">';break;
  192.     case 'bottom': echo '<frameset id="menuFrame" rows="*,'.$menuFrameSize.'" frameborder="no" framespacing="0" border="0">';break;
  193.     case 'right': echo '<frameset id="menuFrame" cols="*,'.$menuFrameSize.'" frameborder="no" framespacing="0" border="0">';break;
  194.     case 'left': echo '<frameset id="menuFrame" cols="'.$menuFrameSize.',*" frameborder="no" framespacing="0" border="0">';break;
  195. }
  196.  
  197. // Left / top menu
  198. if($menuFramePosition=='left' || $menuFramePosition=='top') echo '<frame src="menuFrame.php" name="menuFrame" frameborder="yes" border="1" noresize scrolling="'.$menuFrameScrolling.'">'."\n";
  199.  
  200. // main frame
  201. echo '<frame src="'.$mfSource.'" name="mainFrame" frameborder="no" border="0" noresize scrolling="NO">';
  202.  
  203. // Right / bottom menu
  204. if($menuFramePosition=='right' || $menuFramePosition=='bottom') echo '<frame src="menuFrame.php" name="menuFrame" frameborder="yes" border="1" noresize scrolling="'.$menuFrameScrolling.'">'."\n";
  205. ?>
  206. </frameset>
  207. </HTML>